package com.yiboshi.rehrs.util;

import cn.hutool.core.util.StrUtil;

import java.util.LinkedHashMap;
import java.util.Map;

public class MapBuilder<K, V> {

    Map<K, V> map = new LinkedHashMap<>();

    public V get(K key) {
        return map.get(key);
    }

    public MapBuilder put(K key, V value) {
        if (value == null) {
            return this;
        }
        if (StrUtil.isEmptyIfStr(value)) {
            return this;
        }
        map.put(key, value);
        return this;
    }

    public static <K, V> MapBuilder<K, V> start(K key, V value) {
        return new MapBuilder().put(key, value);
    }

    public static MapBuilder start() {
        return new MapBuilder();
    }

    public Map<K, V> end() {
        return map;
    }
}
